from dda import DDADrawLine, precompute_steps
from bresenham import BresenhamDrawLine, precompute_bresenham_deltas
from graph import plot_comparison

# 预计算步骤表
step_table = precompute_steps()
bresenham_delta_table = precompute_bresenham_deltas()

# 定义测试用例
test_cases = [
    # (0, 0, 10, 5),
    # (0, 0, 5, 10),
    # (0, 0, 10, 10),
    # (5, 5, 15, 5),
    # (5, 5, 5, 15),
    (1, 1, 7, 9),
    # (1, 1, 8, 11),
    # (1, 1, 9, 7)
]

# 设置是否启用优化
use_optimization = True

for i, (x1, y1, x2, y2) in enumerate(test_cases):
    dda_points = DDADrawLine(x1, y1, x2, y2, optimize=use_optimization, step_table=step_table if use_optimization else None)
    bresenham_points = BresenhamDrawLine(x1, y1, x2, y2, optimize=use_optimization, delta_table=bresenham_delta_table if use_optimization else None)

    print(f"DDA Test case {i + 1}: Points: {dda_points}")
    print(f"Bresenham Test case {i + 1}: Points: {bresenham_points}")
    
    plot_comparison(dda_points, bresenham_points, f"Test case {i + 1}")
